Switch to mkdocs material theme for documentation#9849
Switch to mkdocs material theme for documentation#9849browniebroke wants to merge 34 commits intoencode:mainfrom
Conversation
…mkdocs-material # Conflicts: # docs/theme/stylesheets/extra.css # mkdocs.yml
# Conflicts: # requirements/requirements-documentation.txt
|
Configured a dummy RTD project to have a live deployment of the PR: https://browniebroke-drf--2.org.readthedocs.build/en/2/ |
At first glance, that seems like a lot of "red" to me 😊 Making the square burgundy almost feels like they are outlines for an error/danger callout... That being said I think you have a point that the white ones don't look great either |
9d84ed0 to
1f7feaa
Compare
|
I think this pretty much ready for merge now. Unless there is any objections or blocking issue found, I'm planning to merge it in a few days. |
There was a problem hiding this comment.
Pull request overview
This PR migrates the project’s documentation site from the legacy custom MkDocs theme to MkDocs Material, carrying forward custom branding and restoring syntax highlighting behavior.
Changes:
- Switch MkDocs theme to
materialand enable Material navigation/code/search features. - Add a new
docs/theme/override theme with custom CSS, images, and JS to re-enable prettify-based highlighting. - Add Read the Docs configuration and update the documentation homepage markup/assets.
Reviewed changes
Copilot reviewed 20 out of 31 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pyproject.toml |
Adds mkdocs-material[imaging] to the docs dependency group. |
mkdocs.yml |
Switches to Material theme, enables features, and updates extensions/assets. |
docs_theme/nav.html |
Removes legacy theme navigation template. |
docs_theme/main.html |
Removes legacy theme base template and old JS/CSS wiring. |
docs_theme/js/theme.js |
Removes legacy theme JS (incl. prettyprint class injection). |
docs_theme/js/copy-button.js |
Removes legacy code-copy button JS (Material provides copy feature). |
docs_theme/js/bootstrap-2.1.1-min.js |
Removes vendored Bootstrap JS from the legacy theme. |
docs_theme/css/default.css |
Removes legacy theme CSS. |
docs_theme/css/copy-button.css |
Removes legacy copy-button CSS. |
docs_theme/css/bootstrap-responsive.css |
Removes legacy responsive Bootstrap CSS. |
docs_theme/404.html |
Removes legacy theme 404 template. |
docs_theme/img/glyphicons-halflings.png |
Removes legacy theme asset. |
docs_theme/img/glyphicons-halflings-white.png |
Removes legacy theme asset. |
docs/theme/main.html |
Adds Material template override to run prettify on instant navigation. |
docs/theme/stylesheets/extra.css |
Adds Material theme customizations (colors, badges layout, blockquotes, background). |
docs/theme/stylesheets/prettify.css |
Adds dark-scheme prettify styles. |
docs/theme/js/prettify-1.0.js |
Vendors prettify JS for syntax highlighting. |
docs/theme/img/logo.png |
Adds theme logo for header/branding. |
docs/theme/img/grid.png |
Adds background image used by custom CSS. |
docs/theme/img/favicon.ico |
Adds theme favicon. |
docs/theme/src/drf-logos.fig |
Adds logo source asset via Git LFS pointer. |
docs/theme/src/README.md |
Documents the logo source file location. |
docs/index.md |
Updates homepage markup, uses Material light/dark logo switching, and converts code blocks to fenced code. |
.readthedocs.yaml |
Adds RTD build config to build MkDocs using the docs dependency group. |
.gitignore |
Stops ignoring all dotfiles and adds common coverage/cache ignores. |
.gitattributes |
Configures Git LFS tracking for the .fig source asset. |
Comments suppressed due to low confidence (1)
docs/theme/stylesheets/prettify.css:16
- This file uses CSS nesting (
[data-md-color-scheme="slate"] { .com { ... } }), which is not supported in all browsers unless you have a build step that transpiles it. Also, there’s an extra semicolon in.str, .atv { color: #e37e8e;; }. Consider flattening the selectors (e.g., prefix each rule with[data-md-color-scheme="slate"]) and fixing the stray semicolon to keep the stylesheet valid and broadly compatible.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - content.tabs.link | ||
| - content.code.annotate | ||
| - content.code.copy | ||
| - navigation.tabs | ||
| - navigation.tabs.sticky | ||
| - navigation.instant | ||
| - navigation.instant.prefetch | ||
| - navigation.instant.progress | ||
| - navigation.path | ||
| - navigation.sections | ||
| - navigation.top | ||
| - navigation.tracking | ||
| - search.suggest | ||
| - toc.follow | ||
| - toc.integrate |
There was a problem hiding this comment.
theme.features is not valid YAML here: the list entries are aligned with features: instead of being indented under it. As written, the - content.* and - navigation.* items become sibling keys (or cause a parse error), so MkDocs will fail to load the config. Indent the feature list items under features:.
| - content.tabs.link | |
| - content.code.annotate | |
| - content.code.copy | |
| - navigation.tabs | |
| - navigation.tabs.sticky | |
| - navigation.instant | |
| - navigation.instant.prefetch | |
| - navigation.instant.progress | |
| - navigation.path | |
| - navigation.sections | |
| - navigation.top | |
| - navigation.tracking | |
| - search.suggest | |
| - toc.follow | |
| - toc.integrate | |
| - content.tabs.link | |
| - content.code.annotate | |
| - content.code.copy | |
| - navigation.tabs | |
| - navigation.tabs.sticky | |
| - navigation.instant | |
| - navigation.instant.prefetch | |
| - navigation.instant.progress | |
| - navigation.path | |
| - navigation.sections | |
| - navigation.top | |
| - navigation.tracking | |
| - search.suggest | |
| - toc.follow | |
| - toc.integrate |
| .badges { | ||
| display: flex; | ||
| flex-direction: row-reverse; | ||
| align-content: end; |
There was a problem hiding this comment.
In .badges, align-content: end; won’t have any effect because the container doesn’t wrap (flex-wrap defaults to nowrap). If the intent is to vertically align the badges within the row, use align-items (and likely flex-end) instead, or explicitly enable wrapping if you meant align-content.
| align-content: end; | |
| align-items: flex-end; |





Description
Explore replacing our theme by mkdocs-material.
Light theme:
Dark theme:
Some things I'm not happy about:
Syntax highlighting for code snippets is lost unless we switch to code fences (no idea how it works now)figured it out and ported the exiting solution to limit the diffSyntax highlighting
Existing solution relies on
prettify-1.0.jswhich is apprently coming from https://github.com/googlearchive/code-prettifytheme.jswhich adds the classprettyprintto all<pre>tagsprettyPrint()on load (via theonloadHTML attribute). This function finds all elements with the class above and add syntax highliting to themI've replicated this in mkdocs-material, however there is some client side navigation, which means we need to listen to another event than DOM content loaded. This is explained in their docs